<!-- meta page description: PNG DISPLAY DRIVER -->

<em>PNG display driver</em> to create PNG, PPM, or BMP images.

<h2>DESCRIPTION</h2>

The PNG driver generates PNG, PPM, or BMP images from GRASS display
commands. Per default PNG files are written with this driver. This
driver is used by default if <em><a href="cairodriver.html">Cairo
driver</a></em> is not available.

<h2>USAGE</h2>

<h3>Environment variables</h3>

The PNG driver can be enabled by setting <b>GRASS_RENDER_IMMEDIATE</b>
variable, eg.

<div class="code"><pre>
export GRASS_RENDER_IMMEDIATE=png
</pre></div>

Several environment variables affect the operation of the PNG driver:

<ul>
  <li><b>GRASS_RENDER_WIDTH=xxx</b><br>
     the width of the image map (default is 640).
  </li>
  <li><b>GRASS_RENDER_HEIGHT=yyy</b><br>
    the height of the image map (default is 480).
  </li>
  <li><b>GRASS_RENDER_BACKGROUNDCOLOR=RRGGBB</b><br>
    specifies the background color to use in RGB notation (hex or
    R:G:B values). Named colors are also supported. Default
    is <b>FFFFFF</b> (white).
  </li>
  <li><b>GRASS_RENDER_TRANSPARENT=[TRUE|FALSE]</b><br>
    sets transparent background on (TRUE) or off (FALSE, default).
  </li>
  <li><b>GRASS_RENDER_TRUECOLOR=[TRUE|FALSE]</b><br>
    sets true-color support. Default is TRUE.
  </li>
  <li><b>GRASS_RENDER_FILE=filename</b><br>
     the filename to put the resulting image in, default is <tt>map.png</tt>.
     If you set GRASS_RENDER_FILE to a filename which ends in ".ppm", a PPM 
     file will be created (with alpha channel stored in a PGM image, if applicable).
     If you set GRASS_RENDER_FILE to a filename which ends in ".bmp", a 32-bpp
     BMP file will be created (these are not readable by some older viewers).
  </li>
  <li><b>GRASS_RENDER_FILE_COMPRESSION=[0|1|9]</b><br>
    compression level of PNG files (0 = none, 1 = fastest, 9 = best, default is 6)
  </li>
  <li><b>GRASS_RENDER_FILE_READ</b><br>
     if <tt>TRUE</tt>, the PNG driver will initialize the image from
     the contents of GRASS_RENDER_FILE.
  </li>
  <li><b>GRASS_RENDER_FILE_MAPPED</b><br>
    if <tt>TRUE</tt>, the PNG driver
    will map GRASS_RENDER_FILE as its framebuffer, rather than using
    memory. This only works with BMP files.
  </li>
</ul>

<h3>Example</h3>

<div class="code"><pre>
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_TRUECOLOR=TRUE

g.region raster=elevation
d.rast elevation
d.vect roadsmajor color=red
</pre></div>

This writes a file named <tt>map.png</tt> in your current directory.

<h2>NOTES</h2> 

The PNG driver uses the libpng (see
the <a href="http://www.libpng.org/pub/png/">libpng</a> home page) and
zlib (see the
<a href="http://www.zlib.net">zlib</a> home page), all which needs to
be installed for the PNG driver to work (it's worth it).

<p>The resolution of the output images is defined by current region
extents. Use <tt>g.region -p</tt> to get the number of rows and cols
and use the environment variables to set the image size. If you would
like a larger image, multiply both rows and cols by the same whole
number to preserve the aspect ratio.

<p>Further PNG file processing (e.g. quantization to 1 bit for monochrome
images) can be done with <tt>pnmquant</tt> of
the <a href="http://netpbm.sourceforge.net/">netpbm</a> tools.

<h2>SEE ALSO</h2>
<em>
  <a href="cairodriver.html">Cairo driver</a>,
  <a href="psdriver.html">PS driver</a>,
  <a href="htmldriver.html">HTML driver</a>,
  <a href="variables.html">variables</a>
  <br><br>
  <a href="d.rast.html">d.rast</a>,
  <a href="d.vect.html">d.vect</a>,
  <a href="d.mon.html">d.mon</a>,
  <a href="d.erase.html">d.erase</a>,
  <a href="d.redraw.html">d.redraw</a>
</em>

<h2>AUTHOR</h2>

Original version: Per Henrik Johansen &lt;<i>phj (at)
norgit.no</i>&gt; <!-- broken link <I><a href="http://www.norgit.no">NORGIT AS</a></i> -->
<br>
Rewritten by: Glynn Clements, 2003

<!--
<p>
<i>Last changed: $Date$</i>
-->
